﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IMIS_ERP.Web.Sale_Fee
{
	public partial class Modify_Reply : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int sfID = (Convert.ToInt32(Request.Params["id"]));
					ShowInfo(sfID);
				}
			}
		}

		/// <summary>绑定数据：详细信息
		///     <remarks>2010-12-08 河大信管团队</remarks>
		/// </summary>
		/// <param name="sfID">编号</param>
		private void ShowInfo(int sfID)
		{
			IMIS_ERP.BLL.Sale_Fee bll = new IMIS_ERP.BLL.Sale_Fee();
			IMIS_ERP.BLL.Head_User bll2 = new BLL.Head_User();
			IMIS_ERP.Model.Sale_Fee model = bll.GetModel(sfID);
			this.huName.Text = bll2.GetModel(model.sfHuID).huName;
			this.lblsfID.Text = model.sfID.ToString();
			this.txtsfHuID.Text = model.sfHuID;
			this.txtsfTime.Text = model.sfTime.ToString();
			this.txtsfTitle.Text = model.sfTitle;
			this.txtsfReason.Text = model.sfReason;
			this.txtsfFee.Text = model.sfFee.ToString();
			this.txtsfReply.Text = model.sfReply;
			if (model.sfIsRead)
			{
                lblMessage.Text = "已经审批过，不能二次审批！";
				this.btnNot.Enabled = false;
				this.btnSave.Enabled = false;
				//Response.Redirect("List.aspx?msg=u");
			}
			

		}

		public void btnSave_Click(object sender, EventArgs e)
		{


			IMIS_ERP.Model.Sale_Fee model = new IMIS_ERP.Model.Sale_Fee();
			int sfID = int.Parse(this.lblsfID.Text.Trim());
			model.sfID = sfID;
			model.sfHuID = this.txtsfHuID.Text;
			model.sfTime = DateTime.Parse(this.txtsfTime.Text.Trim());
			model.sfTitle = this.txtsfTitle.Text;
			model.sfReason = this.txtsfReason.Text;
			model.sfFee = decimal.Parse(this.txtsfFee.Text.Trim());
			model.sfReply = this.txtsfReply.Text;
			model.sfIsPassed = true;
			model.sfIsRead = true;
			IMIS_ERP.BLL.Sale_Fee bll = new IMIS_ERP.BLL.Sale_Fee();
			if (bll.Update(model))
			{
				Response.Redirect("List_All.aspx?msg=u");
			}
			else
			{
				lblMessage.Text = "修改信息失败,请重试";
			}

		}
		public void btnNot_Click(object sender, EventArgs e)
		{


			IMIS_ERP.Model.Sale_Fee model = new IMIS_ERP.Model.Sale_Fee();
			int sfID = int.Parse(this.lblsfID.Text.Trim());
			model.sfID = sfID;
			model.sfHuID = this.txtsfHuID.Text;
			model.sfTime = DateTime.Parse(this.txtsfTime.Text.Trim());
			model.sfTitle = this.txtsfTitle.Text;
			model.sfReason = this.txtsfReason.Text;
			model.sfFee = decimal.Parse(this.txtsfFee.Text.Trim());
			model.sfReply = this.txtsfReply.Text;
			model.sfIsPassed = false;
			model.sfIsRead = true;
			IMIS_ERP.BLL.Sale_Fee bll = new IMIS_ERP.BLL.Sale_Fee();
			if (bll.Update(model))
			{
                Response.Redirect("List_All.aspx?msg=u");
			}
			else
			{
				lblMessage.Text = "修改信息失败,请重试";
			}

		}

	  

	}
}